#import "WWSimpleImageViewIBInspector.h"
#import "WWSimpleImageView.h"
#import "aspectRatios.h"

@implementation WWSimpleImageViewIBInspector

- init 
{
   char buf[MAXPATHLEN + 1];
   id bundle;
    
   [super init];
    
   bundle = [NXBundle bundleForClass:[self class]];
   [bundle getPath:buf forResource:"WWSimpleImageViewIBInspector" ofType:"nib"];
   [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
   [self revert:nil];

   return self;
}

- revert:sender 
{ 
   [theColor setColor:[object backgroundColor]];
   [alphaSlider setFloatValue:[object alpha]];
   [theImage setStringValue:""];
   [aspectRatioMatrix selectCellWithTag:[object aspectRatioType]];
   [horizontalLayoutMatrix selectCellWithTag:[object horizontalLayoutType]];
   [verticalLayoutMatrix selectCellWithTag:[object verticalLayoutType]];
   [customAspectRatioText setFloatValue:[object aspectRatio]];
   [customAspectRatioText setEnabled:([object aspectRatioType] == WW_ASPECT_CUSTOM)];
   [scaleSwitch setIntValue:(int)[(WWSimpleImageView *)object scaleToFit]];
   [imageUnderSwitch setIntValue:[object imageUnder]];
   [rotateTo setFloatValue:[object frameAngle]];
   [borderTypeMatrix selectCellWithTag:[object borderType]];
 
   return self;
}

- sizeToImage:s { [object sizeToImage:s]; [self revert:nil]; return [super ok:s]; }
- takeColor_:s	{ [object setBackgroundColor:[theColor color]]; [self revert:nil]; return [super ok:s]; }
- setAlpha_:s	{ [object setBackgroundAlpha:[s floatValue]]; [self revert:nil]; return [super ok:s]; }
- setImage_:s	{ [object setImageFile:(char *)[s stringValue]]; [self revert:nil]; return [super ok:s]; }
- setAspectRatio_:s	{ [object setAspectRatio:s]; [self revert:nil]; return [super ok:s]; }
- setImageUnder_:s	{ [object setImageUnder:[s intValue]]; [self revert:nil]; return [super ok:s]; }
- setScale_:s	{ [object setScaleToFit:[s intValue]]; [self revert:nil]; return [super ok:s]; }
- setAspectRatioFromMatrix_:s	{ [object setAspectRatioFromMatrix:s]; [self revert:nil]; return [super ok:s]; }
- setHorizontalLayoutFromMatrix_:s	{ [object setHorizontalLayoutFromMatrix:s]; [self revert:nil]; return [super ok:s]; }
- setBorderTypeFromMatrix_:s	{ [object setBorderType:[[s selectedCell] tag]]; [self revert:nil]; return [super ok:s]; }
- setVerticalLayoutFromMatrix_:s	{ [object setVerticalLayoutFromMatrix:s]; [self revert:nil]; return [super ok:s]; }
- rotateTo_:s { [object rotateTo:[s floatValue]];  [object display]; [self revert:nil]; return [super ok:s]; }

- (BOOL)wantsButtons	{ return NO; }
@end

